package webone.registered.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.ibatis.session.SqlSession;

import webone.javabean.Emp;
import webone.usersDAO.EmpDAOMapper;
import webone.usersDAO.WebOneSqlSession;


@WebServlet("/queryServlet")
public class QueryServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       

    public QueryServlet() {
        super();
    }

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		SqlSession session=WebOneSqlSession.getSqlSession();
		EmpDAOMapper empM=session.getMapper(EmpDAOMapper.class);
		Emp emp=empM.getEmpByName(request.getParameter("username"));
		request.setAttribute("username", emp.getName());
		request.setAttribute("authority", emp.getUt());
		request.getRequestDispatcher("/authority-manager.jsp").forward(request, response);
		
	}
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req,resp);
	}

}
